import java.util.Scanner;
import java.lang.String;

public class Main{
    public static void main(String[] arg){
        Scanner sc = new Scanner(System.in);
        String input1 = sc.next();
        String input2 = sc.next();
        String match = input1.toLowerCase();
        String input = input2.toLowerCase();
        int len1 = match.length();
        int len2 = input.length();
        
        boolean res = matching(match, input, 0, 0, len1, len2);
        System.out.println(res);
        
    }
    public static boolean matching(String match, String input, int i, int j, int len1, int len2){
        // i 指向match，j 指向input
        // 两个字符串同时结束
        if( (i == len1) && (j == len2) ){
            return true;
        }
        // 两个字符串同时结束返回false
        if( (i == len1) || (j == len2) ){
            return false;
        }
        
        char c1 = match.charAt(i);
        char c2 = input.charAt(j);
        
        if(c1 == '?'){
            // 检测匹配字符合法性
            if( ('a' <= c2 && c2 <= 'z') || ('0' <= c2 && c2 <= '9') ){
                return matching(match, input, i + 1, j + 1, len1, len2);
            }
            return false;
        }else if(c1 == '*'){
            // 防止碰到多个连续 ‘*’ 而提高算法复杂度。多个 ‘*’ 效果等同于一个
            if( ('a' <= c2 && c2 <= 'z') || ('0' <= c2 && c2 <= '9') ){
                while((i+1) < len1 && (match.charAt(i+1) == '*')){
                    i = i + 1;
                }
                return matching(match, input, i + 1, j, len1, len2) ||    // '*' 匹配0个字符，i+1，j不动
                    matching(match, input, i + 1, j + 1, len1, len2) ||   // '*' 匹配1个字符，i，j都继续移动
                    matching(match, input, i, j + 1, len1, len2);         // '*' 匹配多个个字符，i不动，j+1
            }
            return false;
        } else if(c1 == c2){
            // 当前两个字符相等则进入下一个字符的匹配
            return matching(match, input, i + 1, j + 1, len1, len2);
        }
        return false;
    }
}